<script>
	import Vue from "vue"
	export default {
		globalData: {
			Custom: 0,
			CustomBar: 0,
			StatusBar: 0
		},
		onLaunch: function() {
			uni.getSystemInfo({
				success: function(e) {
					// #ifndef MP
					Vue.prototype.StatusBar = e.statusBarHeight;
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
					};
					// #endif
	
					// #ifdef MP-WEIXIN
					let systemInfo = wx.getSystemInfoSync()
					Vue.prototype.$StatusBar = systemInfo.statusBarHeight;
					let custom = wx.getMenuButtonBoundingClientRect();
					Vue.prototype.$Custom = custom;
					Vue.prototype.$CustomBar = custom.bottom + custom.top - systemInfo.statusBarHeight + 4;
					// #endif		
	
					// #ifdef MP-ALIPAY
					Vue.prototype.StatusBar = e.statusBarHeight;
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			});
			
			// #ifdef APP-PLUS
			// 消息推送
			// 在线推送点击
			uni.onPushMessage((res) => {
				console.log("在线推送消息: " + JSON.stringify(res));
				if(res.type === 'receive'){
					uni.createPushMessage({
						title: res.data.title,
						content: res.data.content,
						payload: res.data.payload,
						success:(res)=> {
							
						},
						fail:(res)=>{
							
						}
					})
				}
			});
			
			// 点击通知消息时 执行该事件
			plus.push.addEventListener("click", function(message) {
				// 自定义内容获取
				let payload = message.payload;
				try {
					// 完成业务逻辑代码
					
				} catch(e) {
					//TODO handle the exception
				}
			});
			
			// 收到透传消息时 执行该事件
			plus.push.addEventListener("receive", function(message) {
				// 自定义内容获取
				let payload = message.payload;
				try {
					// 完成业务逻辑代码
					
				} catch(e) {
					//TODO handle the exception
				}
			});
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	@import "colorui/main.css";
	@import "colorui/icon.css";
	@import "uview-ui/index.scss";
	/*每个页面公共css */
</style>
